<template>
    <div class="box">
        <div class="title">
            <p>男女比例</p>
            <img src="../../images/dataScreen-title.png" />
        </div>
        <div class="sex">
            <div class="man">
                <img src="../../images/man.png" />
            </div>
            <div class="woman">
                <img src="../../images/woman.png" />
            </div>
        </div>
        <div class="rate">
            <p>男士58%</p>
            <p>女士42%</p>
        </div>
        <div class="charts" ref="chartsRef"></div>
    </div>
</template>

<script setup lang='ts' name='Sex'>
import * as echarts from 'echarts'
const chartsRef = ref()

onMounted(() => {
    let myChart = echarts.init(chartsRef.value);
    myChart.setOption({
        title: {
            text: '男女比例',
            textStyle: {
                color: 'skyblue'
            },
            left: '40%'
        },
        xAxis: {
            show: false,
            min: 0,
            max: 100,
        },
        yAxis: {
            show: false,
            type: 'category',
        },
        series: [{
            type: 'bar',
            data: [58],
            barWidth: 15,
            z: 100,
            itemStyle: {
                color: 'skyblue',
                borderRadius: [20, 20, 20, 20]
            }
        },
        {
            type: 'bar',
            data: [100],
            barWidth: 15,
            // 调整位置
            barGap: '-100%',
            itemStyle: {
                color: 'pink',
                borderRadius: [20, 20, 20, 20]
            }
        }],
        grid: {
            left: 40,
            right: 40,
            bottom: 0,
            top: 20
        }

    });
});
</script>

<style scoped lang='scss'>
.box {
    width: 100%;
    height: 100%;
    background: url(../../images/dataScreen-main-cb.png) no-repeat;
    background-size: 100% 100%;
    margin-top: 10px;

    .title {
        margin-left: 10px;

        p {
            color: white;
            font-size: 20px;
            margin-top: 20px;
        }
    }

    .sex {
        display: flex;
        justify-content: center;

        .man {
            background: url(../../images/man-bg.png) no-repeat;
            width: 111px;
            height: 116px;
            display: flex;
            justify-content: center;
            align-items: center;
            margin: 20px;
        }

        .woman {
            background: url(../../images/woman-bg.png) no-repeat;
            width: 111px;
            height: 116px;
            display: flex;
            justify-content: center;
            align-items: center;
            margin: 20px;
        }

    }

    .rate {
        display: flex;
        justify-content: space-between;
        padding: 10px 50px;
        color: white;
        font-size: 16px;

    }

    .charts {
        width: 100%;
        height: 60px;
        margin-top: -30px;
    }

}
</style>